package com.zoroki.student_score_system.controller;

import com.zoroki.student_score_system.domain.Class;
import com.zoroki.student_score_system.domain.User;
import com.zoroki.student_score_system.service.ClassService;
import com.zoroki.student_score_system.utils.Msg;
import com.zoroki.student_score_system.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/class")
public class ClassController {
    @Autowired
    private ClassService classService;

    @GetMapping("/findAllClass")
    public @ResponseBody Result<List<Class>> findAllClass() {
        return new Result<>(0,classService.findAllClass(), Msg.SUCCESS);
    }

    @GetMapping("/getClassById")
    public @ResponseBody Result<Class> getClassById(int id) {
        return new Result<>(0,classService.getClassById(id),Msg.SUCCESS);
    }

    @PostMapping("/deleteClassById")
    public @ResponseBody Result<Boolean> deleteClassById(int id) {
        return new Result<>(0,classService.deleteClassById(id),Msg.SUCCESS);
    }

    @PostMapping("/addClass")
    public @ResponseBody Result<Boolean> addClass(@RequestBody Class classInfo) {
        return new Result<>(0,classService.addClass(classInfo),Msg.SUCCESS);
    }
}
